package com.lpc.dagger2test.module;

import android.content.Context;

import com.lpc.dagger2test.bean.Student;
import com.lpc.dagger2test.bean.User;

import javax.inject.Named;
import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * 功能:
 * <p>
 * 描述:
 * <p>
 * Created by lipc0113 on 2018/7/27.
 */
@Module
public class UserModule {

    /**
     * Singleton--单例，同时Component也要加上这个注解
     * 同一个Component中才能保持单例
     *
     * @return
     */
    @Singleton
    @Provides
    User providerUser() {
        return new User(101, "lpc");
    }

    @Named("Context")
    @Provides
    Student providerStudent(Context context) {
        return new Student(context);
    }

    @Named("None")
    @Provides
    Student providerStudent2() {
        return new Student();
    }
}
